package com.longxi.tianjintianbao.ui.activity.equipment;

import android.content.Intent;
import android.support.v7.widget.RecyclerView;

import com.longxi.tianjintianbao.R;
import com.longxi.tianjintianbao.ui.base.BaseActivity;
import com.longxi.tianjintianbao.ui.presenter.equipment.EquipmentAtPresenter;
import com.longxi.tianjintianbao.ui.view.equipment.IEquipmentAtView;
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
import com.scwang.smartrefresh.layout.api.RefreshLayout;
import com.scwang.smartrefresh.layout.listener.OnRefreshLoadMoreListener;

/**
 * 设备管理
 */
public class EquipmentActivity extends BaseActivity<IEquipmentAtView, EquipmentAtPresenter> implements IEquipmentAtView {

    private final String TAG = "EquipmentActivity";
    @Override
    protected int provideContentViewId() {
        return R.layout.activity_general_refresh_list;
    }

    @Override
    public void initData() {
        super.initData();
        mPresenter.setBar();
        mPresenter.initAdapter();
    }

    @Override
    public void initListener() {
        super.initListener();
        mIvRight.setOnClickListener(v -> mPresenter.scan());
        mRefreshLayout.setOnRefreshLoadMoreListener(new OnRefreshLoadMoreListener() {

            @Override
            public void onLoadMore(RefreshLayout refreshLayout) {
                mPresenter.page++;
                mPresenter.getEquipmentType();
            }

            @Override
            public void onRefresh(RefreshLayout refreshLayout) {
                mPresenter.page = 0;
                mPresenter.getEquipmentType();
            }

        });
        mPresenter.getEquipmentType();
    }

    @Override
    protected EquipmentAtPresenter createPresenter() {
        return new EquipmentAtPresenter(this);
    }

    @Override
    public SmartRefreshLayout getRefreshLayout() {
        return mRefreshLayout;
    }

    @Override
    public RecyclerView getRvContent() {
        return mRvContent;
    }

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if(RESULT_OK != resultCode){
            return;
        }
        mPresenter.onActivityResult(requestCode, data);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
    }
}
